<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="销售日期" prop="saleTime">
        <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
          range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['erp:ErpCommodity:export']">列表导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="ErpCommodityList" border>
      <el-table-column label="商品编号" align="center" prop="commodityNo" sortable/>
      <el-table-column label="商品名称" align="center" prop="commodityName" />
      <el-table-column label="商品类别" align="center" prop="commodityType" sortable/>
      <el-table-column label="品牌" align="center" prop="commodityBrand" sortable/>
      <el-table-column label="规格" align="center" prop="commoditySpec" sortable/>
      <el-table-column label="基本单位" align="center" prop="unitName" />
      <el-table-column label="发货数量" align="center" prop="saleNumber" sortable/>
      <el-table-column label="库存数量" align="center" prop="commodityNumber" sortable/>
      <el-table-column label="补货数量" align="center" prop="inventoryLowerLimit" sortable/>
    </el-table>
    <!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" /> -->


  </div>
</template>

<script>
import { getSummaryStockList } from "@/api/erp/ErpSale";
export default {
  name: "ErpCommodity",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      dateRange: [],
      // 商品管理表格数据
      ErpCommodityList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        commodityNo: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询商品管理列表 */
    getList() {
      this.loading = true;
      getSummaryStockList( this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.ErpCommodityList = response.data;
        // this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
     /** 导出按钮操作 */
     handleExport() {
      this.download('erp/ErpSale/exportSummaryStock', {
        ...this.queryParams
      }, `汇总备货_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="css" scoped>
::v-deep .el-table .cell {
  padding-left: 1px !important;
  padding-right: 1px !important;
}
</style>
